/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ipercube.sample;

import com.ipercube.Column;
import com.ipercube.DataMap;
import com.ipercube.Measure;
import com.ipercube.Pivot;
import com.ipercube.Row;
import java.util.List;

/**
 *
 * @author tartur
 */
public class SampleVisualizer {

    private Pivot pivot;

    public SampleVisualizer(Pivot pivot) {
        this.pivot = pivot;
    }

    private void out(String s) {
        System.out.print(s);
    }

    private void out(String s, int n) {
        for (int i = 0; i < n; i++) {
            System.out.print(s);
        }
    }

    private void newLine() {
        System.out.println();
    }

    public void show() {
        int rowLevel = pivot.getRowModel().getMaxLevel();
        int colLevel = pivot.getColumnModel().getMaxLevel();
        Column[] colByLevel = pivot.getColumns();
        Row[] rowByLevel = pivot.getRows();
        for (int i = 0; i <= colLevel; i++) {
            out("\t", rowLevel + 2);
            for (Column col : colByLevel) {
                out(col.getValueByLevel(i) + "\t");
            }
            newLine();
        }
        for (Row row : rowByLevel) {
            for (int i = 0; i <= rowLevel; i++) {
                out(row.getValueByLevel(i) + "\t");
            }
            for (Column col : colByLevel) {
                Measure m = pivot.getMeasureAt(row, col);
                out(m.getValue() + "\t");
            }
            newLine();
        }
    }
}
